package com.jy.modules.cims.common.sysUtils;

/**
 * @description String 工具
 * @version v1.0
 * @author ShengZhoutao
 * @Date 2012-9-27
 */
public final class SimpleStringUtils extends org.apache.commons.lang3.StringUtils {

	/**
	 * <p>拼接多个输入字符串</p>
	 * 
	 * @param param
	 * @return
	 */
	public static String append(Object... param) {
		StringBuffer result = new StringBuffer();
		for (Object str : param) {
			result.append(str);
		}
		return result.toString();
	}

	/**
	 * <p>判断输入字符串是否有值(内容)。false：输入为空，或者空字符串；true：输入有值。</p>
	 * <pre>
     * StringUtils.isBlank(null)      = false
     * StringUtils.isBlank("")        = false
     * StringUtils.isBlank(" ")       = false
     * StringUtils.isBlank("bob")     = true
     * StringUtils.isBlank("  bob  ") = true
     * </pre>
	 * @param str
	 * @return
	 */
	public static boolean hasText(String str) {
		if (str == null) {
			return false;
		}

		if (EMPTY.equals(str.trim())) {
			return false;
		}

		return true;
	}

	/**
	 * 格式化字符串
	 * 
	 * 例：formateString("xxx{0}bbb",1) = xxx1bbb
	 * 
	 * @param str
	 * @param params
	 * @return
	 */
	public static String formateString(String str, String... params) {
		for (int i = 0; i < params.length; i++) {
			str = str.replace("{" + i + "}", params[i] == null ? EMPTY : params[i]);
		}
		return str;
	}
	/**
	 * 带【,】的字符串拼接成支持#{dto.creditCode}的in查询
	 * @Title formatStringToSql
	 * @Description TODO
	 * @param str
	 * @return 
	 * String 
	 * @author lizhiqiang
	 * @date 2016-6-7-下午4:52:35
	 * @update 
	 * @throws
	 */
	public static String formatStringToSql(String str){
		if(EMPTY.equals(str)){
			return "";
		}
		if(str.endsWith(",")){
			str = str.substring(0,str.length()-1);
		}
		str = str.replace(",", "','");
		return str;
	}
}